﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects.DataClasses;

namespace Ovvio.Business
{
    /// <summary>
    /// Helper class for default values
    /// </summary>
    public static class EntityDefaults
    {
        /// <summary>
        /// Returns default entity set name in english
        /// </summary>
        /// <typeparam name="TEntity">EntityObject</typeparam>
        /// <returns>Entity set name</returns>
        public static string GetEntitySet<TEntity>() where TEntity : EntityObject, new()
        {
            var name = typeof(TEntity).Name;

            if (name.EndsWith("y"))
                return name.Substring(0, name.Length - 1) + "ies";
            else if (name.EndsWith("s"))
                return name + "es";
            else
                return name + "s";
        }
    }
}
